package com.bugbuff.dubbo.server.service;

import cn.hutool.core.util.ObjectUtil;
import com.alibaba.dubbo.config.annotation.Reference;
import com.bugbuff.dubbo.server.api.RecommendUserApi;
import com.bugbuff.dubbo.server.pojo.RecommendUser;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RecommendUserService {

    @Reference
    private RecommendUserApi recommendUserApi;

    public RecommendUser getRecommendUser(Long id) {
        return recommendUserApi.queryByToUserId(id);
    }

    public List<RecommendUser> queryList(Long id, Integer page, Integer size) {
        return recommendUserApi.queryList(id, page, size);
    }

    /**
     * 查询推荐好友的缘分值
     *
     * @param userId
     * @param toUserId
     * @return
     */
    public Double queryScore(Long userId, Long toUserId){
        Double score = this.recommendUserApi.queryScore(userId, toUserId);
        if(ObjectUtil.isNotEmpty(score)){
            return score;
        }
        //默认值
        return 98d;
    }

    public List<RecommendUser> queryCardList(Long id, Integer count) {
        return recommendUserApi.queryCardList(id, count);
    }
}
